var t = getApp();

Page({
    data: {
        list: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        this.getData();
    },
    getData: function() {
        var a = this, o = t.getNetAddresss("plugin.luck-draw.frontend.index.getPrize");
        t._postNetWork({
            url: o,
            data: {
                activity_id: a.options.id
            },
            success: function(t) {
                var o = t.data;
                1 == o.result ? a.setData({
                    list: o.data.data,
                    isLoadMore: !0,
                    total_page: o.data.last_page
                }) : wx.showToast({
                    title: o.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    _getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var o = t.getNetAddresss("plugin.luck-draw.frontend.index.getPrize");
            t._postNetWork({
                url: o,
                data: {
                    activity_id: this.options.id,
                    turn_num: this.options.num,
                    page: this.data.page
                },
                success: function(t) {
                    var o = t.data;
                    if (a.data.isLoadMore = !0, 1 === o.result) {
                        var e = o.data.data, i = a.data.list.concat(e);
                        a.setData({
                            list: i
                        });
                    } else a.data.page = a.data.page - 1, a.data.isLoadMore = !1;
                }
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});